<<<<<<< HEAD
#include "window3.h"
#include "window2.h"
#include<QPainter>
#include"mybutton.h"
#include<QTimer>
#include "mywindow.h"
window3::window3(QWidget *parent) : QMainWindow(parent)
{
    this->setFixedSize(1080,900);
    MyButton*db=new MyButton(":/db1.png");
    db->setParent(this);
    db->move(975,350);
    db->setIconSize(QSize(100000,100000));
    MyButton *back=new MyButton(":/back.png");
    back->setParent(this);

    back->move(5,5);
    back->setIconSize(QSize(40,40));
    connect(back,&MyButton::clicked,this,[=](){
       emit Back();
    });
    MyButton *set_tower=new MyButton(":/22/button3.png");
    set_tower->setParent(this);
    set_tower->move(800,800);
    set_tower->setIconSize(QSize(this->width(),this->height()));
    connect(set_tower,&MyButton::clicked,this,&window3::set_tower);
    MyButton *tower_fire=new MyButton(":/wb.png");
    tower_fire->setParent(this);
    tower_fire->move(50,400);
    tower_fire->setIconSize(QSize(this->width(),this->height()));
    connect(tower_fire,&MyButton::clicked,this,&window3::addMyObject2);
    QTimer *timer=new QTimer (this);
    connect(timer,&QTimer::timeout,this,&window3::updateScene);
     timer->start(10);

}
void window3::paintEvent(QPaintEvent *){
    QPainter painter(this);
    QPixmap pix(":/map3.png");

    painter.drawPixmap(0,0,1080,1200,pix);
    QPainter painttower(this);
    foreach(Tower *tower,tower_list)
        tower->draw(&painttower);
    foreach(bullet *bulluet1,bullet_list)
        bulluet1->draw(&painter);
    foreach(MyObject*object,object_list)
        object->draw(&painter);
    foreach(MyObject2*object,object2_list)
        object->draw(&painter);


}

void window3::set_tower(){
    Tower *newtower=new Tower(QPoint(540,540),":/negeta1.png");
    tower_list.push_back(newtower);
    update();

}

void window3::updatescreen(){
    update();
}
void window3::addMyObject(){
    MyObject*object=new MyObject(QPoint(100,100),QPoint(400,400),":/m2.gif");
    object_list.push_back(object);
    object->move();
    update();
}
void window3::updateScene(){
    foreach(MyObject2*object,object2_list)
        object->move();
    update();
}
void window3::addMyObject2(){
    MyObject2*object=new MyObject2(QPoint(325,325),QPoint(900,325),":/m2.gif");
    object2_list.push_back(object);

    update();
}
//void window3::showInfo(QPainter*painter){
//    painter->save();
//    painter->setPen(Qt::red);
//    painter->drawText(QRect(100,100,100,50),QString("num1: %1 num2: %2").arg(num1).arg(num2));
//    painter->restore();
//}
=======
#include "window3.h"
#include "window2.h"
#include<QPainter>
#include"mybutton.h"
#include<QTimer>
#include "mywindow.h"
window3::window3(QWidget *parent) : QMainWindow(parent)
{
    this->setFixedSize(1080,900);
    MyButton*db=new MyButton(":/db1.png");
    db->setParent(this);
    db->move(975,350);
    db->setIconSize(QSize(100000,100000));
    MyButton *back=new MyButton(":/back.png");
    back->setParent(this);

    back->move(5,5);
    back->setIconSize(QSize(40,40));
    connect(back,&MyButton::clicked,this,[=](){
       emit Back();
    });
    MyButton *set_tower=new MyButton(":/22/button3.png");
    set_tower->setParent(this);
    set_tower->move(800,800);
    set_tower->setIconSize(QSize(this->width(),this->height()));
    connect(set_tower,&MyButton::clicked,this,&window3::set_tower);
    MyButton *tower_fire=new MyButton(":/wb.png");
    tower_fire->setParent(this);
    tower_fire->move(50,400);
    tower_fire->setIconSize(QSize(this->width(),this->height()));
    connect(tower_fire,&MyButton::clicked,this,&window3::addMyObject2);
    QTimer *timer=new QTimer (this);
    connect(timer,&QTimer::timeout,this,&window3::updateScene);
     timer->start(10);

}
void window3::paintEvent(QPaintEvent *){
    QPainter painter(this);
    QPixmap pix(":/map3.png");

    painter.drawPixmap(0,0,1080,1200,pix);
    QPainter painttower(this);
    foreach(Tower *tower,tower_list)
        tower->draw(&painttower);
    foreach(bullet *bulluet1,bullet_list)
        bulluet1->draw(&painter);
    foreach(MyObject*object,object_list)
        object->draw(&painter);
    foreach(MyObject2*object,object2_list)
        object->draw(&painter);


}

void window3::set_tower(){
    Tower *newtower=new Tower(QPoint(540,540),":/negeta1.png");
    tower_list.push_back(newtower);
    update();

}

void window3::updatescreen(){
    update();
}
void window3::addMyObject(){
    MyObject*object=new MyObject(QPoint(100,100),QPoint(400,400),":/m2.gif");
    object_list.push_back(object);
    object->move();
    update();
}
void window3::updateScene(){
    foreach(MyObject2*object,object2_list)
        object->move();
    update();
}
void window3::addMyObject2(){
    MyObject2*object=new MyObject2(QPoint(325,325),QPoint(900,325),":/m2.gif");
    object2_list.push_back(object);

    update();
}
//void window3::showInfo(QPainter*painter){
//    painter->save();
//    painter->setPen(Qt::red);
//    painter->drawText(QRect(100,100,100,50),QString("num1: %1 num2: %2").arg(num1).arg(num2));
//    painter->restore();
//}
>>>>>>> 199f3fb0e9bc83f97607ce663cfb658435caaa4f
